package org.opens.controller;

import com.baomidou.mybatisplus.extension.api.R;
import org.opens.dao.FndAppendixDao;
import org.opens.entity.FndAppendixEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 功能描述
 *
 * @author by zhangyuming
 * @date 2023/2/2
 */
@RestController
@RequestMapping(value = "/fnd")
public class FndController {

    @Autowired
    private FndAppendixDao fndAppendixDao;

    @RequestMapping(value = "/select")
    public R<FndAppendixEntity> selectById(@RequestParam(value = "id") String id) {
        return R.ok(fndAppendixDao.selectById(id));
    }

    @RequestMapping(value = "/insert")
    public R<FndAppendixEntity> insert(@RequestParam(value = "id") String id) {
        FndAppendixEntity entity = fndAppendixDao.selectById(id);
        fndAppendixDao.insert(entity);
        return R.ok(entity);
    }

    @RequestMapping(value = "/update")
    public R<String> update(@RequestParam(value = "id") String id) {
        FndAppendixEntity entity = fndAppendixDao.selectById(id);
        entity.setTempFlag("N");
        fndAppendixDao.dynamicUpdateById(entity);
        return R.ok("success");
    }

}
